package nl.nhl.idp.Components.Network;

/**
 * Creates byte arrays for messages
 * @author Mark van der Wal
 *
 */
public class ProtocolEncoder 
{
	static public byte[] EncodeTurn(byte value)
	{
		// create buffer
		byte[] buffer = new byte[3];
		
		// put the opcode in
		buffer[0] = (byte)( ProtocolOpcodes.T_TURN.Opcode() & 0xFF00);
		buffer[1] = (byte)( ProtocolOpcodes.T_TURN.Opcode() & 0x00FF);
		buffer[2] = value;
		
		return buffer;
	}
	
	static public byte[] EncodeDrive(byte value)
	{
		// create buffer
		byte[] buffer = new byte[3];
		
		// put the opcode in
		buffer[0] = (byte)( ProtocolOpcodes.T_DRIVE.Opcode() & 0xFF00);
		buffer[1] = (byte)( ProtocolOpcodes.T_DRIVE.Opcode() & 0x00FF);
		buffer[2] = value;
		
		return buffer;
	}
	
	static public byte[] EncodeCommand(byte value)
	{
		// create buffer
		byte[] buffer = new byte[3];
		
		// put the opcode in
		buffer[0] = (byte)( ProtocolOpcodes.T_COMMAND.Opcode() & 0xFF00);
		buffer[1] = (byte)( ProtocolOpcodes.T_COMMAND.Opcode() & 0x00FF);
		buffer[2] = value;
		
		return buffer;
	}
}
